package com.j48.entrancegurad.service.impl;

import com.j48.entrancegurad.mapper.OpinionMapper;
import com.j48.entrancegurad.model.Opinion;
import com.j48.entrancegurad.service.IOpinionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
@Service
public class OpinionService implements IOpinionService {
    @Autowired
    private OpinionMapper opiniondao;

    /**
     * 查询全部意见
     * @return
     */
    @Override
    public ArrayList<Opinion> selectAll() {
        ArrayList<Opinion> lists=new ArrayList<>();
        lists=opiniondao.selectAll();
        if (lists.size()>0){
            return lists;
        }
        return null;
    }

    /**
     * 按id查询意见
     * @param opinion
     * @return
     */
    @Override
    public Opinion selectById(Opinion opinion) {
        Opinion op=new Opinion();
        op=opiniondao.selectById(opinion);
        if (op!=null){
            return op;
        }
        return null;
    }

    /**
     * 查询全部已处理意见
     * @return
     */
    @Override
    public ArrayList<Opinion> selectAllfinished(){
        return opiniondao.selectAllfinished();
    }

    /**
     * 查询全部未读意见
     * @return
     */
    @Override
    public ArrayList<Opinion> selectAllNotRead() {
        return opiniondao.selectAllAble();
    }

    /**
     * 按用户id查询意见
     * @param opinion
     * @return
     */
    @Override
    public ArrayList<Opinion> selectByUserId(Opinion opinion) {
        return opiniondao.selectByUserId(opinion);
    }

    /**
     * 按用户id查询意见
     * @param opinion
     * @return
     */
    @Override
    public ArrayList<Opinion> selectByUserId1(Opinion opinion) {
        return opiniondao.selectByUserId1(opinion);
    }

    /**
     * 更新意见状态
     * @param opinion
     * @return
     */
    @Override
    public int updatestatus(Opinion opinion) {
        return opiniondao.update(opinion);
    }

    /**
     * 按id删除意见
     * @param opinion
     * @return
     */
    @Override
    public int deleteById(Opinion opinion) {
        return opiniondao.deleteById(opinion);
    }

    /**
     * 更新意见处理时间
     * @param opinion
     * @return
     */
    @Override
    public int updatetime(Opinion opinion) {
        return opiniondao.updatetime(opinion);
    }
}
